package core;

import common.LiteCalculationException;

public class CalculateCore {
	
	private CalculateCore(){ }
	
	public static Double calculate(Double arg1, Double arg2, Integer operation) throws LiteCalculationException
	{
		switch (operation)
		{
			case OperationConst.ADDITION:
				return add(arg1, arg2);
			/*case OperationConst.SUBTRACTION:
				return subtract(arg1, arg2);
			case OperationConst.MULTIPLICATION:
				return multiply(arg1, arg2);
			case OperationConst.DIVISION:
				return divide(arg1, arg2);*/
			default:
				throw new LiteCalculationException("Er: unknown operation");
		}
	}
	
	public static double add(double arg1, double arg2)
	{
		System.out.println(arg1 + " + " + arg2);
		return arg1 + arg2;
	}
	
	public double subtract(double arg1, double arg2)
	{
		System.out.println(arg1 + " - " + arg2);
		return arg1 - arg2;
	}
	
	public double multiply(double arg1, double arg2)
	{
		System.out.println(arg1 + " * " + arg2);
		return arg1 * arg2;
	}
	
	public double divide(double arg1, double arg2) throws LiteCalculationException
	{
		System.out.println(arg1 + " / " + arg2);
		if (arg2 == 0)
		{
			throw new LiteCalculationException("Er: division by zero");
		}
		
		return arg1 / arg2;
	}
	
}
